package org.sysdance.aplicativo.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DataUtil {

	private static final String DD_MM_YYYY = "dd/MM/yyyy";

	private DataUtil() {
		super();
	}
	
	public static Boolean isData(final Object o){
		return (o != null) && (o instanceof Date);
	}
	
	public static Boolean isData(final String data){
		final SimpleDateFormat sdf = new SimpleDateFormat(DD_MM_YYYY);
		sdf.setLenient(false);
		try {
			sdf.parse(data);
			return true;
		} catch (ParseException e) {
			return false;
		}
	}
	
	public static String getDataFormatada(final Date data){
		return new SimpleDateFormat(DD_MM_YYYY).format(data);
	}
	
	public static Integer getAno(final Date data){
		final Calendar calendario = Calendar.getInstance();
		calendario.setTime(data);
		return calendario.get(Calendar.YEAR);
	}
	
}
